<%@ page contentType="text/html;charset=utf-8"%>
<%@ page
	import="java.io.*, java.sql.*, java.util.*, java.text.*, napal.*, util.*, napal.*"%>
<%@ page import="org.apache.ibatis.*"%>
<%@ page import="java.util.Date"%>
<%
	request.setCharacterEncoding("utf-8");
	String cmd = request.getParameter("cmd");
	String m = (String)session.getAttribute("managerRank");

 	if(m==null){ %>
	<script language=javascript>
				self.window.alert("권한이 없습니다.");
				location.href="Main.jsp?";
			</script>
<%}
 	%>

<%@ include file="./Header.jsp"%>
		</td>
		</TR>
		<TR HEIGHT="100">
		<td>
		<a href="ExtensionApp.jsp" class="btn btn-link btn-small">연장승인<br></a><br><br>
			<%
				if ("extension".equals(cmd)) {
					int extensionID = Integer.parseInt(request
							.getParameter("extensionID"));
					RentalHome.Extension(extensionID);  %>
					<script language=javascript>
							self.window.alert("연장승인하였습니다.");
							location.href="ExtensionApp.jsp";
				</script>
					
					<%
				}
			
			if ("refuse".equals(cmd)) {
				int extensionID = Integer.parseInt(request
						.getParameter("extensionID"));
				RentalHome.ExtensionRefuse(extensionID);  %>
				<script language=javascript>
						self.window.alert("연장신청을 거절하였습니다.");
						location.href="ExtensionApp.jsp";
			</script>
				
				<%
			}
			%>
		
			<table class="table" width="100%">
				<Tr>
					<td>대여상태</td>
					<td>카테고리명</td>
					<td>모델명</td>
					<td>기자재관리번호</td>
					<td>대여시작날짜</td>
					<td>대여기간</td>
					<td>학과이름</td>
					<td>이름</td>
					<td>학번</td>
					<td>연락처</td>
					<td>연장승인</td>
					<td>연장거절</td>
				</Tr>
				<%
					for (Return r : RentalHome.ExtensionApp()) {
				%>
				<TR>
					<form onsubmit="return confirm('해당 기자재를 연장승인/거절하시겠습니까?');">
						<TD><%=r.get대여상태()%></td>
						<td><%=r.get카테고리명()%></td>
						<td><%=r.get모델명()%></td>
						<Td><%=r.get기자재관리번호()%></td>
						<td><%=r.get대여시작날짜()%></td>
						<td><%=r.get대여기간()%></td>
						<td><%=r.get학과이름()%></td>
						<td><%=r.get이름()%></td>
						<Td><%=r.get학번()%></td>
						<td><%=r.get연락처()%></td>
						<input type=hidden name="extensionID"
							value="<%=r.get대여번호()%>">
						<td>
							<%
								if (!r.get대여상태().equals("반납완료")) {
							%> <input name="cmd" class="btn btn-inverse" type=submit
							value="extension">
							
							</td>
							<td><input name="cmd" class="btn btn-inverse" type=submit
							value="refuse"> <%
 	}
 %>
						
					</form>
				</TR>
				<%
					}
				%>
			</table>
			
			
			
			
			
			</td>
		</tr>
		<TR HEIGHT="50">
			<TD><%@ include file="./bottom.jsp"%></TD>
		</TR>
	</TABLE>
</body>
</html>